import 'package:car_map/widget/load_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_swiper/flutter_swiper.dart';

import 'morepage/more_router.dart';
import 'routers/fluro_navigator.dart';

///开屏介绍页
class SplashPage extends StatefulWidget {
  @override
  _splashState createState() => _splashState();
}

class _splashState extends State<SplashPage> {
  List<String> list = [
    'splash/app_start_1',
    'splash/app_start_2',
    'splash/app_start_3'
  ];

  _goLogin() {
    NavigatorUtils.push(context, MoreRouter.indexPage, replace: true);
  }

  @override
  Widget build(BuildContext context) {
    // TODO: implement build
    ScreenUtil.instance = ScreenUtil(width: 750, height: 1334)..init(context);
    return Scaffold(
      body: Container(
          child: Swiper(
        itemCount: list.length,
        pagination: new SwiperPagination(),
        autoplay: false,
        loop: false,
        itemBuilder: (context, index) {
          return Stack(
            children: <Widget>[
              LoadAssetImage(
                list[index],
                key: Key(list[index]),
                fit: BoxFit.cover,
                width: double.infinity,
                height: double.infinity,
                format: 'jpg',
              ),
              Positioned(
                  left: ScreenUtil().setWidth(330),
                  bottom: ScreenUtil().setHeight(80.0),
                  child: Offstage(
                    offstage: index!=2,
                    child: InkWell(
                      onTap: (){
                        _goLogin();
                      },
                      child: Container(
                        alignment: Alignment.center,
                        width: ScreenUtil().setWidth(100.0),
                        padding: EdgeInsets.all(5.0),
                        decoration: BoxDecoration(
                            borderRadius: BorderRadius.all(Radius.circular(5.0)),
                            border:
                            Border.all(color: Colors.deepOrange, width: 1)),
                        child: Text(
                          '开启',
                          style: TextStyle(
                              fontSize: ScreenUtil().setSp(25.0),
                              color: Colors.deepOrange),
                        ),
                      ),
                    ),
                  ))
            ],
          );
        },
      )),
    );
  }
}
